package puyu.manage.service.utils.tree;

import lombok.Data;
import lombok.NoArgsConstructor;
import puyu.manage.service.utils.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
public class Zone implements Serializable{

    private static final long serialVersionUID = -1528175948190672440L;

    //主ID
    private String id;

    //主编码
    private String code;

    //主名称
    private String name;

    //父ID
    private String pid;

    //父编码
    private String pCode;

    //父名称
    private String pName;

    private String type;

    //子项
    private List<Zone> children;

    private BigDecimal fileTotal;

    private BigDecimal fileSize;

    private String icon;
    private String lev;

    private Boolean disabled;

    private String isDataScope;

    private String unitType;

    private String accountingBodyType;


    public String getPid() {
        return StringUtils.isEmpty(pid)?"":pid;
    }

    public String getPCode() {
        return StringUtils.isEmpty(pCode)?"":pCode;
    }

    public Zone(String id, String name, String pid) {
        this.id = id;
        this.name = name;
        this.pid = pid;
    }

    public Zone(String id, String code, String name, String pid, String pCode, String pName, String type, List<Zone> children, String lev) {
        this.id = id;
        this.code = code;
        this.name = name;
        this.pid = pid;
        this.pCode = pCode;
        this.pName = pName;
        this.type = type;
        this.children = children;
        this.lev = lev;
    }

    public void addChildren(Zone zone) {
        if (children == null) {
            children = new ArrayList<>();
        }
        children.add(zone);
    }
}
